package com.cw.jeeyt.service.converter.system;

import java.util.ArrayList;
import java.util.List;

import com.cw.jeeyt.service.bo.system.SystemTemplateModuleListBo;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.dao.model.system.SystemTemplateModuleListDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 模板模块清单转换类
 *
 * @author chenw
 * @date 2020-02-23 20:42:03
 */
public class SystemTemplateModuleListConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static SystemTemplateModuleListBo do2Bo(SystemTemplateModuleListDo model) {
        SystemTemplateModuleListBo bo = new SystemTemplateModuleListBo();
        if (model == null) {
            return bo;
        }
        bo.setId(model.getId());
        bo.setModuleCode(model.getModuleCode());
        bo.setModuleName(model.getModuleName());
        bo.setModulePath(model.getModulePath());
        bo.setModuleComment(model.getModuleComment());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static SystemTemplateModuleListDo bo2Do(SystemTemplateModuleListBo bo) {
        SystemTemplateModuleListDo model = new SystemTemplateModuleListDo();
        if (bo == null) {
            return model;
        }
        model.setId(bo.getId());
        model.setModuleCode(bo.getModuleCode());
        model.setModuleName(bo.getModuleName());
        model.setModulePath(bo.getModulePath());
        model.setModuleComment(bo.getModuleComment());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<SystemTemplateModuleListBo> doList2BoList(List<SystemTemplateModuleListDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SystemTemplateModuleListConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<SystemTemplateModuleListDo> boList2DoList(List<SystemTemplateModuleListBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SystemTemplateModuleListConverter::bo2Do));
    }
}
